import java.util.Arrays;
import java.util.Scanner;
public class Test {
    public static void main(String[] args) {
        int[] array = new int[]{1,3,5,7,9};
        reverse(array);
        System.out.println(Arrays.toString(array));
    }
    public static void reverse(int[] array) {
        if(array == null) {
            return;
        }
        int i =0;
        int j = array.length-1;
        while(i < j) {
            int temp = array[i];
            array[i] = array[j];
            array[j] = temp;
            i++;
            j--;
        }
    }
    public static void main7(String[] args) {
        //冒泡排序  升序
        int[] array = new int[]{1,3,5,7,9,2,4,6,8,10};
        bubblesort(array);
        System.out.println(Arrays.toString(array));
    }
    public static void bubblesort(int[] array) {
        if(array == null){
            return;
        }
        for (int i = 0; i < array.length - 1; i++) { //趟数
            boolean flg = true;
            for (int j = 0; j < array.length - 1 - i; j++) { //每趟比较的个数
                if(array[j] > array[j+1])
                {
                    int temp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = temp;
                    flg = false;
                }
            }
            if(flg){
                break;
            }
        }
    }
    public static void main6(String[] args) {
        int[] array = {1,2,3,4};
        System.out.println(myToString(array));
        System.out.println(Arrays.toString(array));
    }
    public static String myToString(int[] array){
        if(array==null){
            return "null";
        }
        if(array.length==0){
            return "[]";
        }
        String ret = "[ ";
        for (int i = 0; i < array.length; i++) {
            ret += array[i];
            if(i!= array.length-1){
                ret += ", ";
            }
        }
        ret += " ]";
        return ret;
    }
    public static void main5(String[] arg){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int ret = fib(n);
        System.out.println("第"+n+"个斐波那契数为"+ret);
        //循环实现斐波那契数列
        int a = 0;
        int b = 1;
        int c = 0;
        while(n>2){
            c = a+b;
            a = b;
            b=c;
            n--;
        }
        System.out.println(c);
    }
    public static int fib(int n){//递归实现斐波那契数列
        if(n==1){
            return 0;
        }else if(n==2){
            return 1;
        }
        return fib(n-1)+fib(n-2);
    }
    public static int fun4(int n){
        if(n<10){
            return n;
        }
        return n%10+fun4(n/10);
    }
    public static void main4(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int ret = fun4(n);
        System.out.println(ret);
    }
    public static int fun3(int n){
        if(n==1){
            return 1;
        }
        return n+fun3(n-1);
    }
    public static void main3(String[] args){
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int sum = fun3(x);
        System.out.println(sum);
    }
    public static void print2(int n){
        if(n>9){
            print(n/10);
            System.out.print(n%10);
        }else{
            System.out.print(n);
            return;
        }
    }
    public static void print(int n){
        if(n<10){
            System.out.print(n+"    ");
        }else{
            print(n/10);
            System.out.print(n%10+"    ");
        }
    }
    public static void main2(String[] args){
        //按顺序打印1234
        int n = 1234;
        print(n);
        System.out.println();
        print2(n);
    }
    public static double add(int a,double b,int c){
        return a+b+c;
    }
    public static double add(int a,int b,double c){
        return a+b+c;
    }
    public static void main1(String[] args) {
        int x = 10;
        int y = 20;
        double z = 10.5;
        double sum = add(x,y,z);
        double sum1 = add(x,z,y);
        System.out.println(sum);
        System.out.println(sum1);
    }
}
